﻿// -----------------------------------------------------------------------
// <copyright file="AlwaysSuccessAsyncCommandHandler.cs">
// Copyright (c) 2013 Andrey Veselov. All rights reserved.
// License:  Microsoft Public License (MS-PL)
// Contacts: http://andrey.moveax.com  andrey@moveax.com
// </copyright>
// -----------------------------------------------------------------------

namespace Moveax.DataAccess.Cqrs.Highway.UnitTests.DataAccess.CommandHandlers
{
	using System.Diagnostics.Contracts;
	using System.Threading;
	using System.Threading.Tasks;
	using Moveax.DataAccess.Cqrs.Highway.UnitTests.Model.Commands;

	internal class AlwaysSuccessAsyncCommandHandler : ICommandHandlerAsync<AlwaysSuccessAsyncCommand>
	{
		public AlwaysSuccessAsyncCommandHandler(IRepository repository)
		{
			Contract.Requires(repository != null);
		}

		public Task ExecuteAsync(AlwaysSuccessAsyncCommand command, CancellationToken cancellationToken)
		{
			var tcs = new TaskCompletionSource<bool>();
			tcs.SetResult(true);

			return tcs.Task;
		}
	}
}